package lishizheng.demo05;

//测试守护线程
public class TestDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();


        Thread thread = new Thread(god);
        thread.setDaemon(true);//默认是false，表示是用户线程

        thread.start();//上帝线程

        new Thread(you).start();//用户线程启动


    }
}

class God implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println("上帝保佑着你");
        }
    }
}

class  You implements  Runnable{

    @Override
    public void run() {
        for (int i = 1; i < 100; i++) {
            System.out.println("已经开心活过了"+ i +"年");
        }
        System.out.println("goodbye world");
    }
}